package com.policenacorp.ejb;

import java.util.Hashtable;

import javax.ejb.embeddable.EJBContainer;
import javax.naming.Context;

public class Contexto {

    private final Context context;
    private static Contexto instancia;

    @SuppressWarnings({ "rawtypes", "unchecked" })
    private Contexto() {
	Hashtable env = new Hashtable();
	env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
	context = EJBContainer.createEJBContainer().getContext();
    }

    public static Contexto getInstance() {
	final boolean instanciaNula = null == instancia;
	if (instanciaNula) {
	    instancia = new Contexto();
	}
	return instancia;
    }

    public Context getContext() {
	return context;
    }

}
